package cn.microservices.cloud.common.core.utils;

import io.github.yedaxia.apidocs.Docs;
import io.github.yedaxia.apidocs.DocsConfig;
import org.springframework.beans.factory.annotation.Value;

import java.util.ArrayList;
import java.util.List;

/**
 * 接口文档自动生成工具
 *
 * @author ygc
 */
public class DocUtil {
    public static String DOCS_PATH;
    public static String PROJECT_PATH;
    public static String API_VERSION;

    @Value("${docs.projectPath}")
    public void setProjectPath(String projectPath){
        PROJECT_PATH = projectPath;
    }
    @Value("${docs.docsPath}")
    public void setDocsPath(String docsPath){
        DOCS_PATH = docsPath;
    }
    @Value("${docs.apiVersion}")
    public void setApiVersion(String apiVersion){
        API_VERSION = apiVersion;
    }
    public static void main(String[] args) {
        DocsConfig config = new DocsConfig();
        // 项目根
        //款式模块根目录
        String projectPath = "/Users/chenwen/Desktop/code/microservices/microservicesCodeDubbo/supply-chain/supply-chain-demand";
        config.setProjectPath(projectPath);
        // 项目名称
        config.setProjectName("需求api");
        // 声明该API的版本
        config.setApiVersion("demandJava");
        //生成API 文档所在目录
        String docsPath = "/Users/chenwen/Desktop/code/microservices/microservicesCodeDubbo/docs";
        config.setDocsPath(docsPath);
        // 配置自动生成
        config.setAutoGenerate(Boolean.TRUE);
        // 执行生成文档
        Docs.buildHtmlDocs(config);
        List<String> list2 = new ArrayList<>();
        List<String> list = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            list2.add(list.get(i));
        }
    }
}